package cn.edu.zut.internship.bean.sys;

import java.io.Serializable;
import java.util.*;

/**
 * 封装同一返回对象
 */
public class Result implements Serializable {
    /**
     * 返回编码
     */
    private int code;
    /**
     * 返回信息
     */
    private String message;
    /**
     * 返回列表数据
     */
    private Collection beans;
    /**
     * 返回Map数据
     */
    private Map bean;
    /**
     * .
     */
    private static final int SUCCESS_CODE = 20000;
    /**
     * .
     */
    private static final String SUCCESS_MESSAGE = ErrorCodeEnum.SUCCESS.getMsg();
    /**
     * .
     */
    private static final Result SUCCESS = new Result(SUCCESS_CODE,
            SUCCESS_MESSAGE);
    /**
     * .result构造函数
     */
    public Result(int resultCode, String resultMessage) {
        this.code = resultCode;
        this.message = resultMessage;
    }/**
     * .
     */
    public Result() {
        code = 20000;
        beans = new ArrayList();
        bean = new HashMap();
    }
    /**
     * .
     * @param isSuccess
     */
    public Result(boolean isSuccess) {
        if (isSuccess) {
            this.code = SUCCESS_CODE;
            this.message = SUCCESS_MESSAGE;
        }
    }
    /**
     *
     *〈一句话功能简述〉.
     *〈功能详细描述〉
     * @return SUCCESS
     */
    public static Result success() {
        return SUCCESS;
    }
    /**
     *
     *〈一句话功能简述〉.
     *〈功能详细描述〉
     * @param resultCode resultCode
     * @return SUCCESS_CODE.equals(resultCode)
     */
    public static boolean isSuccessCode(int resultCode) {
        return SUCCESS_CODE==resultCode;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Collection getBeans() {
        return beans;
    }

    public void setBeans(Collection beans) {
        this.beans = beans;
    }

    public Map getBean() {
        return bean;
    }

    public void setBean(Map bean) {
        this.bean = bean;
    }
}
